#!/bin/bash
export PACKAGE_NAME="$DPKG_MAINTSCRIPT_PACKAGE"

if [ "${PACKAGE_NAME}" = "cn.flamescion.bookworm-compatibility-mode" ];then
if [ -d /opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env ];then

mv /opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env /opt/apps/cn.flamescion.bookworm-compatibility-mode/files/ace-env
ln -sfv /opt/apps/cn.flamescion.bookworm-compatibility-mode/files/ace-env /opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env


fi
fi

/opt/apps/$PACKAGE_NAME/files/bin/ace-init

if [ "${PACKAGE_NAME}" = "cn.flamescion.bookworm-compatibility-mode" ];then
systemctl daemon-reload
systemctl enable ace-bookworm-auto-upgrade
systemctl start ace-bookworm-auto-upgrade
        # enable kernel.unprivileged_userns_clone
        # disable kernel.apparmor_restrict_unprivileged_unconfined and kernel.apparmor_restrict_unprivileged_userns
        if [ -f /usr/lib/sysctl.d/amber-ce.conf ];then
                sysctl -p /usr/lib/sysctl.d/amber-ce.conf
        fi

fi

true
